// ==============================================================================================
// GenericInfoPanel.cs
//
// Created by: NI, 2007.03.27
// ==============================================================================================
using System.Windows.Forms;

namespace RibbonExplorer.InfoPanel
{
  // ==============================================================================================
  /// <summary>
  /// This user control implements a generic information panel.
  /// </summary>
  // ==============================================================================================
  public partial class GenericInfoPanel : UserControl
  {
    #region Private fields

    private INavigationSupport _NavSupport;
    private TreeNode _Node;

    #endregion

    #region Lifecycle methods

    // --------------------------------------------------------------------------------------------
    /// <summary>
    /// Creates a new instance of this user control
    /// </summary>
    /// <param name="navSupport">Navigation support service</param>
    // --------------------------------------------------------------------------------------------
    public GenericInfoPanel(INavigationSupport navSupport, TreeNode node)
    {
      InitializeComponent();
      _NavSupport = navSupport;
      PathTree.ImageList = navSupport.GetNavigationImages();
      _Node = node;
      TreeNode path = navSupport.GetPath(_Node);
      if (path != null)
      {
        PathTree.Nodes.Add(path);
      }
      PathTree.ExpandAll();
    }

    #endregion

    #region Public properties

    // --------------------------------------------------------------------------------------------
    /// <summary>
    /// Gets or sets the header text.
    /// </summary>
    // --------------------------------------------------------------------------------------------
    public string HeaderText
    {
      get { return _HeaderLabel.Text; }
      set { _HeaderLabel.Text = value;  }
    }

    #endregion

    private void PathTree_DoubleClick(object sender, System.EventArgs e)
    {
      TreeNode pathNode = PathTree.SelectedNode;
      if (pathNode != null)
      {
        TreeNode destNode = pathNode.Tag as TreeNode;
        if (destNode != null)
        {
          _NavSupport.NavigateTo(destNode);
        }
      }
    }
  }
}
